package com.kun.controller;

import com.hankcs.hanlp.seg.Segment;
import com.hankcs.hanlp.seg.common.Term;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author kun.li
 */
@RestController
public class HelloController {

    @Autowired
    private Segment segment;

    @GetMapping("hello")
    public List<String> hello(String text) {
        List<Term> terms = segment.seg(text);
        List<String> collect = terms.stream().map(term -> term.word).collect(Collectors.toList());
        return collect;
    }
}
